<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/commond/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="connect">
	<div onclick="change_hidden(this)" class="connect_title">
		<span>联系人</span>
		<a onclick="{
			jQ('#addContact').dialog('open');
			if (event.stopPropagation){
				event.stopPropagation();
			}else if (window.event) {
				window.event.cancelBubble = true;
			}
		}" title="添加联系人"></a>
	</div>
	<div class="connect_list"></div>
</div>
<script type="text/javascript">
	// 控制通讯录和筛选条件的title，展开，收起
	function change_hidden(obj){
		jQ(obj).next().slideToggle('normal');
	}
	// 控制通讯录里面的组的收起和缩放
	function OpenClose(obj){
		jQ(obj).nextAll().slideToggle('fast');
		jQ(obj).find('a').toggleClass('open');
		jQ(obj).find('ol:first').toggleClass('frist_on').toggleClass('frist_off');
	}
	function createContentHtml(data,type,typeName){
		var html="<ul>";
		html+="<li class=\"title\" onclick=\"OpenClose(this)\"><a class=\"open\">"+typeName+"</a><span>["+jQ(data).find(type).find("Contact").length+"]</span></li>"
		jQ(data).find(type).find("Contact").each(function(i,d){
			html+="<li>";
			html+="<div class=\"name\">"+jQ(d).find("name").text()+"</div>";
			html+="<div class=\"email_add\">"+jQ(d).find("email").text()+"</div>";
		});
		html+="</ul>";
		return html;
	}
	function InitRight(){
		jQ("div.connect div.connect_list").empty();
		jQ.ajax({
			type:"POST",
			url: "contactAjax!loadContactAll.action",
			success:function(data){
				if(data!=null){
					jQ("div.connect div.connect_list").append(createContentHtml(data,"friend","我的好友"));
					jQ("div.connect div.connect_list").append(createContentHtml(data,"family","家人"));
					jQ("div.connect div.connect_list").append(createContentHtml(data,"work","工作"));
				}
			}
		});
	}
	jQ(function(){
		InitRight();
	});
</script>